package com.wanxi.controller;

import com.wanxi.dto.ResultDto;
import com.wanxi.model.UserModel;
import com.wanxi.service.UserService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @author Li
 * @Date 2023/6/15 16:44
 */
@RestController
@Api(tags = "登录",value = "Open Api")
public class LoginController {
    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public ResultDto login(UserModel userModel,HttpServletRequest req) {
        String sessionCode = (String) req.getSession().getAttribute("vCode");
        userModel.setVCode(sessionCode);
        return userService.login(userModel);
    }


}
